import React from "react"
import { useLocation, useNavigate, useParams } from "react-router-dom"
// import { useNavigate } from "react-router-dom"

function withRouter(Component) {
    return function(props) {
      let location = useLocation(),
        navigate = useNavigate(),
        params = useParams()
      return <Component
          {...props}
          {...{ location, navigate, params }}
          // router={{ location, navigate, params }}
        />
    }
}

// function withRouter2(Comp) {
//   return class withRouterClass extends React.Component {
//     constructor(props) {
//       super(props)
//       this.state = {}
//     }
//     render(h) {
//       let location = useLocation(),
//           navigate = useNavigate(),
//           params = useParams()
//       return <Comp {...this.props} {...{location, navigate, params}} />
//     }
//   }
// }


export default withRouter